﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Configuration;

namespace Talk
{
    public partial class logout : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
          SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["talkconn"].ConnectionString);
          conn.Open();
          string sql = "insert into Actions(UserID,What,Time,IP) values("
            + Session["UserID"].ToString()
            + ",'" + Session["Username"] + "登出','"
            + DateTime.Now.ToString() + "','"
            + Request.UserHostAddress.ToString()
            + "');";
          SqlCommand cmd = new SqlCommand(sql, conn);
          cmd.ExecuteNonQuery();
          conn.Close();
				
            Session.Abandon();
            Response.Redirect("/index.aspx");
        }
    }
}
